Skip to content

Refactor VariableDefinitionVisitor to resolve memory leak issues#90

Merged
Orrison merged 2 commits intomainfrom
memory-leak
Oct 16, 2025
Merged

Refactor VariableDefinitionVisitor to resolve memory leak issues#90
Orrison merged 2 commits intomainfrom
memory-leak

Conversation

@Orrison
Copy link
Owner

@Orrison Orrison commented Oct 16, 2025

Refactor VariableDefinitionVisitor to resolve memory leak issues described in https://phpstan.org/blog/preprocessing-ast-for-custom-rules

…marking and remove unused NodeConnectingVisitor service

Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
@Orrison Orrison requested a review from Copilot October 16, 2025 06:05
@Orrison Orrison added the bug Something isn't working label Oct 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the VariableDefinitionVisitor to eliminate memory leaks by removing the dependency on NodeConnectingVisitor and its associated parent node tracking mechanism. The refactor follows the recommendations from the PHPStan blog post on preprocessing AST for custom rules.

Key Changes:

  • Replaced parent node traversal pattern with direct node type checking
  • Eliminated NodeConnectingVisitor registration which was causing memory retention
  • Introduced recursive markDefinitionTargets() method to handle nested assignment patterns

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Rules/CamelCaseVariableName/VariableDefinitionVisitor.php Refactored visitor logic to check node types directly instead of using parent references, added recursive marking for complex assignment patterns
config/extension.neon Removed NodeConnectingVisitor service registration to prevent memory leaks

…ionVisitor

Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
@Orrison Orrison requested a review from Copilot October 16, 2025 06:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@Orrison Orrison merged commit 5ba2356 into main Oct 16, 2025
5 checks passed
@Orrison Orrison deleted the memory-leak branch October 16, 2025 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants